From: Andrew Cooper Date: Mon, 5 Dec 2016 11:32:59 +0000 (+0000) Subject: x86/shadow: Tweak some initialisation in sh_page_fault() X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~3176 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=6629754fc1793782669dfe6d3c668caf1e6b4e54;p=xen.git x86/shadow: Tweak some initialisation in sh_page_fault() sh_page_fault() is a complicated function. It aids clarity for the reader if constant data is declared as such. Declare struct npfec access and fetch_type_t ft as const, which requires initialising them during declaration. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich Acked-by: Tim Deegan --- diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c index f494f7bd38..67c98b96e1 100644 --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -2860,15 +2860,17 @@ static int sh_page_fault(struct vcpu *v, struct sh_emulate_ctxt emul_ctxt; const struct x86_emulate_ops *emul_ops; int r; - fetch_type_t ft = 0; p2m_type_t p2mt; uint32_t rc; int version; - struct npfec access = { + const struct npfec access = { .read_access = 1, + .write_access = !!(regs->error_code & PFEC_write_access), .gla_valid = 1, .kind = npfec_kind_with_gla }; + const fetch_type_t ft = + access.write_access ? ft_demand_write : ft_demand_read; #if SHADOW_OPTIMIZATIONS & SHOPT_FAST_EMULATION int fast_emul = 0; #endif @@ -2878,9 +2880,6 @@ static int sh_page_fault(struct vcpu *v, perfc_incr(shadow_fault); - if ( regs->error_code & PFEC_write_access ) - access.write_access = 1; - #if SHADOW_OPTIMIZATIONS & SHOPT_FAST_EMULATION /* If faulting frame is successfully emulated in last shadow fault * it's highly likely to reach same emulation action for this frame. @@ -3050,10 +3049,6 @@ static int sh_page_fault(struct vcpu *v, goto propagate; } - /* What kind of access are we dealing with? */ - ft = ((regs->error_code & PFEC_write_access) - ? ft_demand_write : ft_demand_read); - /* What mfn is the guest trying to access? */ gfn = guest_l1e_get_gfn(gw.l1e); gmfn = get_gfn(d, gfn, &p2mt);